
var ConstPicker = require('../../common/const/ConstPicker.js');

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    bindData: {
      type: Object,
      value: {
        title: "T",
        holder: "",
        key: "",
        value: "",
        value1: "",
        barType: "",
        isRequired: true,
        isEnable: true
      },
      observer: function (newVal, oldVal) { }
    },
    index: {
      type: String,
      value: "0",
      observer: function (newVal, oldVal) { }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    barInputType: "",
    showComponent: 0,
    pickerData: {}
  },

  ready: function () {
    var showComponent = -1;
    var barInputType = "";
    var pickerData = [];
    if (this.data.bindData.barType) {
      if (this.data.bindData.barType.indexOf("KeyBoardType:") === 0) {
        showComponent = 1;
        barInputType = this.data.bindData.barType.replace("KeyBoardType:", "");
      } else if (this.data.bindData.barType.indexOf("HZAreaPickerView:file:") === 0) {
        showComponent = 2;
        barInputType = this.data.bindData.barType.replace("HZAreaPickerView:file:", "");
        pickerData = ConstPicker.constPicker[barInputType];
        console.log("pickerData == " + pickerData);
      }
      console.log(showComponent + " -- " + barInputType);
      this.setData({
        showComponent: showComponent,
        barInputType: barInputType
      });
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    inputValueChange: function (e) {
      // console.log(e);
      var myEventDetail = {
        key: this.data.bindData.key
      }
      var id = e.currentTarget.id;
      if(id.indexOf("0") === 0){
        myEventDetail.val0 = e.detail.value;
      }else{
        myEventDetail.val1 = e.detail.value;
      }
      console.log(myEventDetail);
      this.triggerEvent('inputBarValue', myEventDetail) //myevent自定义名称事件，父组件中使用
    },

    pickerValueChange: function (e) {
      // console.log(e);
      var myEventDetail = {
        key: this.data.bindData.key
      }
      var id = e.currentTarget.id;
      if (id.indexOf("0") === 0) {
        myEventDetail.val0 = e.detail.value;
      } else {
        myEventDetail.val1 = e.detail.value;
      }
      console.log(myEventDetail);
      this.triggerEvent('inputBarValue', myEventDetail) //myevent自定义名称事件，父组件中使用
    }
  }

});

